package com.wontube.core.remote;

import com.wontube.client.remote.IAPICheckHandler;
import com.wontube.core.annotation.NoLoginSupport;
import com.wontube.core.conf.VersionInfo;
import com.wontube.core.pub.servlet.handlers.BasicHandler;

/**
 * @author yuechao
 *
 */
@NoLoginSupport
public class APICheckHandler extends BasicHandler implements IAPICheckHandler {
	//private static final String serverAPIVersion = "1.2";
	private static final String minClientAPIVersion = "1.0";
	
	/*
	 * @see com.wontube.smr.client.IAPIChecker#getServerAPIVersion()
	 */
	@Override
	public String getServerAPIVersion() {
		return VersionInfo.versionInfo.getVersion();
	}

	/* 
	 * @see com.wontube.smr.client.IAPIChecker#getMinAPIVersion()
	 */
	@Override
	public String getMinAPIVersion() {
		return minClientAPIVersion;
	}

	/*
	 * @see com.wontube.smr.client.IAPIChecker#isCurrentClientSupported()
	 */
	@Override
	public Boolean isCurrentClientSupported() {
		String clientAPIVersion = super.getContext().getSession().getLastAPIVersion();
		boolean isSupported = minClientAPIVersion.compareTo(clientAPIVersion) <= 0;
		
		return isSupported;
	}
}
